﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class PrintPreview : Form
    {
        ArrayList imageList;
        Form1 theForm1;

        public PrintPreview(Form1 aForm1, ArrayList aL, int aInt)
        {
            InitializeComponent();
            imageList = aL;
            theForm1 = aForm1;

          //  ImageList newil = new ImageList();

          //  newil.ColorDepth = ColorDepth.Depth32Bit;

         //   newil.ImageSize = new Size(200, 400);

            int pSizeW = (int)(panel1.Width * 0.65);
            int pSizeH = (int)(panel1.Height * 0.85);

            int startX = 50;
            int startX1 = 20;

            foreach (object iii in imageList)
            {
               // Image dd = new Bitmap(Path.GetDirectoryName(Application.ExecutablePath).Replace("\\bin\\Debug", "\\Icons\\drive.jpg"));
                
              //  newil.Images.Add(Form1.resizeImage(iii, 200, 400));
            //    
                if (aInt != 3)
                {

                    PictureBox pictureBox11;

                    pictureBox11 = new System.Windows.Forms.PictureBox();
                    panel1.Controls.Add(pictureBox11);

                    pictureBox11.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                    pictureBox11.Location = new System.Drawing.Point(startX, 20);
                    pictureBox11.Name = "pictureBox111";
                    pictureBox11.Size = new System.Drawing.Size(pSizeW, pSizeH);
                    pictureBox11.TabIndex = 13;
                    pictureBox11.TabStop = false;


                }
                else
                {
                    PictureBox pictureBox11;

                    pictureBox11 = new System.Windows.Forms.PictureBox();
                    panel1.Controls.Add(pictureBox11);

                    pictureBox11.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                    pictureBox11.Location = new System.Drawing.Point(startX1, 95);
                    pictureBox11.Name = "pictureBox111";
                    pictureBox11.Size = new System.Drawing.Size(290, 200);
                    pictureBox11.TabIndex = 13;
                    pictureBox11.TabStop = false;

                }



                PictureBox pictureBox1;

                pictureBox1 = new System.Windows.Forms.PictureBox();
                panel1.Controls.Add(pictureBox1);



            //    pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                if (aInt != 3)
                {
                    pictureBox1.Location = new System.Drawing.Point(startX, 20);
                }
                else
                {
                    pictureBox1.Location = new System.Drawing.Point(startX1+20, 115);
                }
                pictureBox1.Name = "pictureBox111";
                if (aInt == 1)
                {
                    pictureBox1.Size = new System.Drawing.Size(pSizeW, pSizeH / 2);
                }
                else if (aInt == 2)
                {
                    pictureBox1.Size = new System.Drawing.Size(pSizeW, pSizeH);
                }
                else if (aInt == 3)
                {
                    pictureBox1.Size = new System.Drawing.Size(250, 160);
                }
                pictureBox1.TabIndex = 131;
                pictureBox1.TabStop = false;
                pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
                pictureBox1.BringToFront();

                Image theImage = (Image)new Bitmap(theForm1.imageLocation[(int)iii]);

                if (aInt == 1)
                {

                    if (theImage.Height > theImage.Width)
                    {
                        theImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    }
                }
                else if (aInt == 2)
                {
                    if (theImage.Height < theImage.Width)
                    {
                        theImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    }
                }
                else if (aInt == 3)
                {
                    if (theImage.Height > theImage.Width)
                    {
                        theImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    }
                }


                pictureBox1.Image = theImage;

               

                pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;






                panel1.Refresh();

                startX = startX + pSizeW + 50;
                startX1 = startX1 + 290 + 20;



            }




            if (aInt != 3)
            {
                PictureBox pictureBox11;

                pictureBox11 = new System.Windows.Forms.PictureBox();
                panel1.Controls.Add(pictureBox11);

                //    pictureBox11.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                pictureBox11.Location = new System.Drawing.Point(startX, 20);
                pictureBox11.Name = "pictureBox111";
                pictureBox11.Size = new System.Drawing.Size(1, 1);
                pictureBox11.TabIndex = 13;
                pictureBox11.TabStop = false;
            }
            else
            {
                PictureBox pictureBox11;

                pictureBox11 = new System.Windows.Forms.PictureBox();
                panel1.Controls.Add(pictureBox11);

                //    pictureBox11.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                pictureBox11.Location = new System.Drawing.Point(startX1, 20);
                pictureBox11.Name = "pictureBox111";
                pictureBox11.Size = new System.Drawing.Size(1, 1);
                pictureBox11.TabIndex = 13;
                pictureBox11.TabStop = false;
            }




         //   
            /*


            listView1.TileSize = new System.Drawing.Size(200, 400);
            this.listView1.View = View.Tile;
            this.listView1.LargeImageList = newil;

            int i = 0;

            ArrayList a = (ArrayList)imageList;

            foreach (object imageIndex in a)
            {
                listView1.Items.Add(theForm1.imageFileNameList[(int)imageIndex]);
                listView1.Items[i].ImageIndex = (int)imageIndex;
                i++;
            }

            */
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {


            Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
         //   autoComplete1.Text.

            Printing at = new Printing();

            at.ShowDialog();

         //   at.sss();

            if (at.done)
            {
                Close();
            }
        }

        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
           // listView1.SelectedItems.Clear();
        }



    }
}
